<?php
include 'config.php';
	$con = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die ("Could not execute query");
	$query = "SELECT * FROM d3";

	$result = mysqli_query($con,$query) or die ("Could not SELECT lexid, context1 FROM d3");
	
	$num =  mysqli_num_rows($result);
		
	$data = array();
    
    for ($x = 0; $x < $num ; $x++) {
         $data[] = mysqli_fetch_assoc($result);
 		
     }
   // echo json_encode($data);   
	
	while ($num = mysqli_fetch_array($result))
    {
    $source  = json_encode($num['source']);
    $id = json_encode($num['id']);
	$type = json_encode($num['type']);
	$context= json_encode($num['context']);
	$title = json_encode($num['title']);
	

// echo ' { "name":' . $id .  ',';
// echo ' "children": [';
	// echo ' { '; 
		// echo '  "name":'  . $context . ',';
		// echo ' "children": [';
		// echo ' { '; 
			// echo ' "name":' . $source .  ',"title":' . $title  ;
			// echo '}';     
		// echo ']';
	// echo ' } ';   
// echo ']';
// echo ' } ';   

	//$jase = '{ "name":' .  $id .',"children": [{ "name":' . $context . ',"children": [{ "name":' .  $source . ',"title":'. $title . '}] }]}}';
	echo $jase;
	}	
	
	 
	
?>
